#include "problem_1.h"


typedef struct _MyPCB {

    struct _MyPCB *next;
    struct PCB *proc;
    int time_remain;
} MyPCB;

MyPCB *waiting_list_head = NULL;
MyPCB *waiting_list_tail = NULL;



/*
 * if the argument is positive, block the current process for the
 * specified number of ticks
 *
 * if the argument is 0 or negative, do nothing
 */
void sys_sleep(int ticks) {

    if (ticks <= 0)
        return;

    int time_cur = get_current_time();
    int wakeup_time = time_cur + ticks;

    struct PCB *proc_cur = current;    
        
    char *pID_cur = current->id;
    
    
    /* do nothing if process is sleeping or is not running */
    if (current->state == READY || current->state == WAITING) 
        return;

    

    /* display message */
    printf("SLEEP CODE: at time %d: putting %s to sleep until %d \n",
            time_cur, pID_cur, wakeup_time);


    // put current process in waiting list
    //

    current->state = WAITING;
    
    //
    // set PCB's link field

    if (waiting_list_head == NULL) {
        waiting_list_head = 

    }


    


}


/*
 * the OS calls this function once per tick; you use it to wake up
 * sleeping processes
 *
 * an awakened process should be put at the head of the ready list
 *
 * make sure you wake up all processes whose time is up, not just
 * one of them
 */
void timer_sleep(void) {



}


/*
 * returns number of processes that are currently waiting on sleep()
 * calls
 */
int num_sleeping (void) {

    return 0;
}

